package day8;

public class carTest {
    public static void main(String[] args) {
        car []arr=new car[3];
        arr[0]=new car();
        arr[1]=new car();
        arr[2]=new car();
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"辆车的数据");
            arr[i].setBand();
            arr[i].setPrice();
            arr[i].setColour();
        }
        double avg=avg(arr);
        System.out.println("平均价格为："+avg);
        int count=0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i].price<avg){
                count++;
                System.out.println(arr[i].getPrice()+","+arr[i].getColour()+","+arr[i].getBand());
            }
        }
        System.out.println("价格比平均值低的有："+count);
    }
    public static double avg (car arr[]){
        double avg=0;
        for (int i = 0; i < arr.length; i++) {
            avg+=arr[i].price;
        }
        avg/=arr.length;
        return avg;
    }

}
